//
//  SKRegisterView.m
//  SKaURobot
//
//  Created by cdong on 16/2/18.
//  Copyright © 2016年 cdong. All rights reserved.
//

#import "SKRegisterView.h"

@implementation SKRegisterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setView];
    }
    return self;
}

- (void)loadNagavitionViewWithString:(NSString *)nameString{
    self.navigationV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 375*matchW, 64)];
    self.navigationV.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_bg"]];
    [self addSubview:self.navigationV];

    self.navigationVL = [[UILabel alloc]initWithFrame:CGRectMake(((self.frame.size.width - 100)/2), 20, 100, 44)];
    self.navigationVL.text = nameString;
    self.navigationVL.textAlignment = NSTextAlignmentCenter;
    self.navigationVL.textColor = [RGBColorEncapsulation colorWithRGB:0xf8f8f8 alpha:1];
    self.navigationVL.font = [UIFont systemFontOfSize:19];
    [self.navigationV addSubview:self.navigationVL];
    //
    self.backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.backBtn.frame = CGRectMake(12*matchW, CGRectGetMinY(self.navigationVL.frame) + 7, 30, 30);
    [self.backBtn setBackgroundImage:[UIImage imageNamed:@"2left"] forState:UIControlStateNormal];
    [self.navigationV addSubview:self.backBtn];
}

- (void)setView{
    [self loadNagavitionViewWithString:@"注册"];
    UIView *mainView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.navigationV.frame), 375*matchW, self.frame.size.height - CGRectGetMaxY(self.navigationV.frame))];
    //????
    mainView.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xf4f4f4 alpha:1];
    [self addSubview:mainView];
    self.phoneImageV = [[UIImageView alloc]initWithFrame:CGRectMake((12+13.5)*matchW, (17+15)*matchH, 26*matchW, 26*matchH)];
    self.phoneImageV.image = [UIImage imageNamed:@"phone"];
    [mainView addSubview:self.phoneImageV];
    self.phoneTF = [[UITextField alloc]initWithFrame:CGRectMake(65*matchW, 17*matchH, self.frame.size.width - 53*matchW - 12*matchW, 60*matchH)];
    self.phoneTF.placeholder = @"请输入手机号";
    if ([self.phoneTF respondsToSelector:@selector(setAttributedPlaceholder:)]) {
        UIColor *color = [RGBColorEncapsulation colorWithRGB:0xbab9ba alpha:1];
        UIFont *font = [UIFont systemFontOfSize:15];
        self.phoneTF.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"请输入手机号" attributes:@{NSForegroundColorAttributeName:color,NSFontAttributeName:font}];
    }
//    self.phoneTF.keyboardType = UIKeyboardTypeNumberPad;
    [mainView addSubview:self.phoneTF];
    
    self.fillV = [[UIView alloc]initWithFrame:CGRectMake(12*matchW, CGRectGetMaxY(self.phoneTF.frame), self.frame.size.width - 24*matchW, 1*matchH)];
    self.fillV.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xe6e6e6 alpha:1];
    [mainView addSubview:self.fillV];
    
    self.identifyCodeImageV = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.phoneImageV.frame), CGRectGetMaxY(self.fillV.frame) + 15, CGRectGetWidth(self.phoneImageV.frame), CGRectGetHeight(self.phoneImageV.frame))];
    self.identifyCodeImageV.image = [UIImage imageNamed:@"Direction"];
    [mainView addSubview:self.identifyCodeImageV];
    
    self.identifyCodeTF = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.phoneTF.frame), CGRectGetMaxY(self.fillV.frame), CGRectGetWidth(self.phoneTF.frame), CGRectGetHeight(self.phoneTF.frame))];
    self.identifyCodeTF.placeholder = @"验证码";
    if ([self.identifyCodeTF respondsToSelector:@selector(setAttributedPlaceholder:)]) {
        UIColor *color = [RGBColorEncapsulation colorWithRGB:0xbab9ba alpha:1];
        UIFont *font = [UIFont systemFontOfSize:15];
        self.identifyCodeTF.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"验证码" attributes:@{NSForegroundColorAttributeName:color,NSFontAttributeName:font}];
    }
    self.identifyCodeTF.keyboardType = UIKeyboardTypeNumberPad;
    [mainView addSubview:self.identifyCodeTF];
    
    self.getIdentifyCodeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.getIdentifyCodeBtn.frame = CGRectMake(CGRectGetMaxX(self.fillV.frame) - 130*matchW, CGRectGetMinY(self.fillV.frame)+10*matchH, 130*matchW, 40*matchH);
    self.getIdentifyCodeBtn.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xcc222a alpha:1];
    [self.getIdentifyCodeBtn setTitle:@"发送验证码" forState:UIControlStateNormal];
    self.getIdentifyCodeBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.getIdentifyCodeBtn setTitleColor:[RGBColorEncapsulation colorWithRGB:0xffffff alpha:1] forState:UIControlStateNormal];
    [self.getIdentifyCodeBtn.layer setMasksToBounds:YES];
    [self.getIdentifyCodeBtn.layer setCornerRadius:3];
    [mainView addSubview:self.getIdentifyCodeBtn];
    self.fillV2 = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.fillV.frame), CGRectGetMaxY(self.identifyCodeTF.frame), CGRectGetWidth(self.fillV.frame), CGRectGetHeight(self.fillV.frame))];
    self.fillV2.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xe6e6e6 alpha:1];
    [mainView addSubview:self.fillV2];
    self.nextRegisterBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    self.nextRegisterBtn.userInteractionEnabled = NO;
    self.nextRegisterBtn.frame = CGRectMake(12*matchW, CGRectGetMaxY(self.fillV2.frame)+30*matchH, self.frame.size.width - 24*matchH, 45*matchH);
    self.nextRegisterBtn.backgroundColor = [RGBColorEncapsulation colorWithRGB:0xcc222a alpha:1];
    [self.nextRegisterBtn setTitle:@"下一步" forState:UIControlStateNormal];
    self.nextRegisterBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    [self.nextRegisterBtn setTitleColor:[RGBColorEncapsulation colorWithRGB:0xffffff alpha:.5] forState:UIControlStateNormal];
    [self.nextRegisterBtn.layer setMasksToBounds:YES];
    [self.nextRegisterBtn.layer setCornerRadius:3];
    [mainView addSubview:self.nextRegisterBtn];
}

@end
